/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package algoritmosgenetico;

/**
 *
 * @author Administrador
 */
public class ProblemReader {

    private int nodesNumber;
    private int whNumber;
    private int[] demand;
    private int[] warehouseCapacity;
    private double[][] costs;
    private int[] fixedCosts;


    /** Creates a new instance of ProblemReader */
    public ProblemReader(String name) {
        readProblem(name);
    }

    public void readProblem(String name){
        try{
            java.io.FileReader i= new java.io.FileReader(new java.io.File(name));
            java.io.BufferedReader br=new java.io.BufferedReader(i);
            String s="";
            s=br.readLine();
            java.util.StringTokenizer str;
            str=new java.util.StringTokenizer(s);
            //se leen el numero de bodegas
            whNumber=Integer.parseInt(str.nextToken());
            //se leen el numero de demandas
            nodesNumber = Integer.parseInt(str.nextToken());
            //Se leen las capacidades de las bodegas y los costos
            warehouseCapacity=new int[whNumber];
            fixedCosts=new int[whNumber];
            for(int k=0;k<whNumber;++k){
                s = br.readLine();
                str = new java.util.StringTokenizer(s);
                String a=str.nextToken();
                warehouseCapacity[k]=Integer.parseInt(a);
                a=str.nextToken();
                fixedCosts[k]=Integer.parseInt(a);
            }           
             //Se leen las demandas y los costos
            demand=new int[nodesNumber];
            costs=new double[nodesNumber][whNumber];
            for(int k=0;k<nodesNumber;++k){
                s = br.readLine();
                str = new java.util.StringTokenizer(s);
                String a=str.nextToken();
                demand[k]=Integer.parseInt(a);
                int cont=0;
                s = br.readLine();
                str = new java.util.StringTokenizer(s);
                for (int j=0;j<7;++j){
                    a=str.nextToken();
                    costs[k][cont]=Double.parseDouble(a);
                    cont=cont+1;
                }
                s = br.readLine();
                str = new java.util.StringTokenizer(s);
                for (int j=0;j<7;++j){
                    a=str.nextToken();
                    costs[k][cont]=Double.parseDouble(a);
                    cont=cont+1;
                }
                s = br.readLine();
                str = new java.util.StringTokenizer(s);
                for (int j=0;j<7;++j){
                    a=str.nextToken();
                    costs[k][cont]=Double.parseDouble(a);
                    cont=cont+1;
                }
                s = br.readLine();
                str = new java.util.StringTokenizer(s);
                for (int j=0;j<4;++j){
                    a=str.nextToken();
                    costs[k][cont]=Double.parseDouble(a);
                    cont=cont+1;
                }
                /**
                s = br.readLine();
                str = new java.util.StringTokenizer(s);
                for (int j=0;j<4;++j){
                    a=str.nextToken();
                    costs[k][cont]=Double.parseDouble(a);
                    cont=cont+1;
                }**/
            
            
            }
            //System.out.println("se leyo el archivo");
            br.close();
        }catch(Exception e){
            System.out.println("ERROR LECTURA");
            System.out.println(e.getMessage()+" "+e.getCause());
        }
    }


     public int getNodesNumber() {
        return nodesNumber;
    }

    public int[] getDemand() {
        return demand;
    }


    public int[] getWarehouseCapacity() {
        return warehouseCapacity;
    }

    public double[][] getCosts() {
        return costs;
    }

    public int[] getFixedCosts() {
        return fixedCosts;
    }

    public int getWhNumber() {
        return whNumber;
    }


   
}


